package com.lmc.chatroom.controller;

import com.lmc.chatroom.mapper.messageMapper;
import com.lmc.chatroom.model.Result;
import com.lmc.chatroom.model.message;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/message")
public class messageController {
    @Autowired
    private messageMapper messageMapper;

    @RequestMapping("/getHistoryMssage")
    public Result getHistoryMssage(Integer sessionId) {
        log.info("getHistoryMssage");
        List<message> historyMessage = messageMapper.getHistoryMessge(sessionId);
        Collections.reverse(historyMessage);
        return Result.success(historyMessage);

    }
}
